<template>
	<view>
		<view class="stage-item" @click="cardclick(item)">
			<image class="shrink-icon" :class="{'up':shrinkType == true}" src="/static/image/push_icon.png" mode="aspectFit" v-if="shrink == true" @click.stop="shrinkTypeChange"></image>
			<view class="item-title-box">
				<view class="num">
					{{item.taskNo}}
				</view>
				<view class="title" :style="shrink == true ? 'font-weight: bold;' : ''">
					{{item.taskName}}
				</view>
				<view class="status-box">
					<view class="status tag">
						{{item.timeStatus}}
					</view>
				</view>
				
			</view>
			<view class="tag-box">
				<view class="tag-item">
					负责人：{{info.leader.userName ? info.leader.userName : '--'}}
				</view>
				<view class="tag-item">
					发起人：{{item.createUser.userName}}
				</view>
				<view class="tag-item">
					分类：{{item.label}}
				</view>
				<view class="tag-item">
					标签：{{item.keyword ? item.keyword : '--'}}
				</view>
			</view>
			<view class="table-box" v-if="shrink == true && shrinkType == true || shrink == false">
				<view class="table-row">
					<view class="table-item title">
						优先级：
					</view>
					<view class="table-item value">
						<view class="tag-radius" :style="{backgroundColor:numberColorList[item.priority]}">
							{{item.priority}}
						</view>
					</view>
					<view class="table-item title">
						重要级：
					</view>
					<view class="table-item value">
						<view class="tag-radius" :style="{backgroundColor:numberColorList[item.importance]}">
							{{item.importance}}
						</view>
					</view>
				</view>
				<view class="table-row">
					<view class="table-item title">
						创建日期：
					</view>
					<view class="table-item value">
						{{item.createTime}}
					</view>
					<view class="table-item title">
						截止日期：
					</view>
					<view class="table-item value">
						{{item.endTime}}
					</view>
				</view>
				<view class="table-row">
					<view class="table-item title">
						预计工时：
					</view>
					<view class="table-item value">
						{{item.expectedHour ? item.expectedHour : '--'}}
					</view>
					<view class="table-item title">
						计划工时：
					</view>
					<view class="table-item value">
						{{item.plannedHour ? item.plannedHour : '--'}}
					</view>
				</view>
				<view class="table-row">
					<view class="table-item title">
						实际工时：
					</view>
					<view class="table-item value">
						{{item.actualHour ? item.actualHour : '--'}}
					</view>
					<view class="table-item title">
						系统统计消耗工时：
					</view>
					<view class="table-item value">
						{{item.systemStatisticalTime ? item.systemStatisticalTime : '--'}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			shrink:{
				type:Boolean,
				default:false,
			},
			info:{
				type:Object,
				default:{}
			},
			borderBottom:{
				type:Boolean,
				default:false,
			},
			shrinkType:{
				type:Boolean,
				default:false,
			},
			index:{
				type:Number,
				default:0
			},
			indextwo:{
				type:Number,
				default:0
			}
		},
		data() {
			return {
				item:{},
				statusList: [{
						id: 0,
						name: "未开始" 
					},
					{
						id: 1,
						name: "进行中",
						color:'#6ea7de',
					},
					{
						id: 2,
						name: "已暂停",
						color:'#fcad4e',
					},
					{
						id: 3,
						name: "完成提报中",
						color:'#147797',
					},
					{
						id: 4,
						name: "异常提报中",
						color:'#c8443f'
					},
					{
						id: 5,
						name: "正常完成",
						color:'#7bc094'
					},
					{
						id: 6,
						name: "异常完成",
						color:'#fe0000'
					}
				],
				numberColorList:['','#d82b58','#f53d33','#fb950d','#f0b75d','#687178'],
			}
		},
		mounted() {
			let info = this.info;
			if(info.priority){
			info.priority = info.priority.substring(0,1);
			}
			if(info.importance){
			info.importance = info.importance.substring(0,1);
			}
			if(info.createTime){
				info.createTime = info.createTime.substring(0,info.createTime.length - 3);
			}
			if(info.endTime){
				info.endTime = info.endTime.substring(0,info.endTime.length - 3);
			}
			this.item = info;
		},
		methods: {
			shrinkTypeChange:function(){
				let data = {indextwo:this.indextwo,index:this.index};
				this.$emit('shrinkTypeChange',data);
			},
			cardclick:function(item){
				this.$emit('tap',item);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.stage-item{
		padding: 20rpx 40rpx;
		padding-right:20rpx;
		box-sizing: border-box;
		width:100%;
		position:relative;
		.shrink-icon{
			position: absolute;
			top: 20rpx;
			left: 0;
			width: 40rpx;
			height: 40rpx;
		}
		.up{
			transform:rotate(180deg);
		}
		.item-title-box{
			display: flex;
			width: 100%;
			position:relative;
			.num{
				font-size: 20rpx;
				background-color: #f6f6f6;
				padding: 0 20rpx;
				line-height: 40rpx;
				border-radius: 10rpx;
			}
			.title{
				font-size: 30rpx;
				margin-left: 20rpx;
				line-height:40rpx;
			}
			.status-box{
				display: flex;
				position: absolute;
				right:0;
				top:0;
				.tag{
					border:1rpx solid #ea0b0b;
					font-size:24rpx;
					line-height: 36rpx;
					height:36rpx;
					padding: 0 15rpx;
					background-color:rgba(234,11,11,0.05);
					color: #ea0b0b;
					margin: 0 10rpx;
					border-radius: 10rpx;
				}
			}
			
		}
		.tag-box{
			display: flex;
			margin: 20rpx 0;
			.tag-item{
				font-size: 20rpx;
				background-color: #f6f6f6;
				// background-color: red;
				line-height: 36rpx;
				// white-space: nowrap;
				margin-right:10rpx;
				border-radius: 10rpx;
				padding: 0 10rpx;
			}
			.tag-item:last-child{
				margin-right: 0;
			}
		}
		.table-box{
			display: table;
			width: 100%;
			.table-row{
				display: table-row;
			}
			.table-item{
				display: table-cell;
				line-height:40rpx;
				.tag-radius{
					border-radius: 100%;
					color: white;
					background-color: #37c315;
					width:40rpx;
					height:40rpx;
					font-size: 24rpx;
					line-height:40rpx;
					text-align: center;
				}
			}
			.table-item:nth-child(3n){
				// padding-left:2%;
				text-align: right;
			}
			.value{
				font-size: 20rpx;
			}
			.title{
				font-size: 20rpx;
			}
		}
	}
</style>
